<?php
/* @var $this HomeController */
/* @var $model Home */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'home-form',
	'htmlOptions' => array('enctype' => 'multipart/form-data'),
	'enableAjaxValidation'=>false,
	'action' => $this->createUrl('parser/update', array('id' => $model->id) )
)); ?>
	<?php echo $form->errorSummary($model); ?>
	<div class="row">
		<?php echo $form->labelEx($model,'type'); ?>
		<?php $list = $model->getTypes();//echo $form->textField($model,'type');?>
		<?php echo $form->dropDownList( $model,'type', $list);?>
		<?php echo $form->error($model,'type'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'city_id'); ?>
		<?php $list = $model->getCities(); ?>
		<?php echo $form->dropDownList( $model,'city_id', $list, array(
		    'prompt'=>'Выберите город',
		    'ajax' => array(
			    'type'=>'POST', 
			    'url'=>$this->createUrl('home/loadmetros'),
			    'update'=>'#fromCity', 
			    'data'=>array('city_id'=>'js:this.value','YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),
		  )));?>
		<?php echo $form->error($model,'city_id'); ?>
	</div>
	<?php // эта часть меняется ajax ?>
	<div id ="fromCity">
		<div class="row">
			<?php echo $form->labelEx($model,'district_id'); ?>
			<?php $list = $model->getDiscricts(); ?>
			<?php echo $form->dropDownList( $model,'district_id', $list, array('prompt'=>'Выберите район'));?>
			<?php echo $form->error($model,'district_id'); ?>
		</div>
		<div class="row">
			<?php echo $form->labelEx($model,'metro_id'); ?>
			<?php $list = $model->getMetros(); ?>
			<?php echo $form->dropDownList( $model,'metro_id', $list, array('prompt'=>'Выберите метро'));?>
			<?php echo $form->error($model,'metro_id'); ?>
		</div>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'street'); ?>
		<?php echo $form->textField($model,'street',array('size'=>60,'maxlength'=>512)); ?>
		<?php echo $form->error($model,'street'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'floor'); ?> / <?php echo $form->labelEx($model,'max_floor'); ?>
		<?php echo $form->textField($model,'floor',array('size'=>8,'maxlength'=>8)); ?> / <?php echo $form->textField($model,'max_floor',array('size'=>8,'maxlength'=>8)); ?>
		<?php echo $form->error($model,'floor'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'house'); ?>
		<?php echo $form->textField($model,'house',array('size'=>8,'maxlength'=>8)); ?>
		<?php echo $form->error($model,'house'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'home'); ?>
		<?php echo $form->textField($model,'home',array('size'=>8,'maxlength'=>8)); ?>
		<?php echo $form->error($model,'house'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'furniture'); ?>
		<?php echo $form->checkBox($model,'furniture'); ?>
		<?php echo $form->error($model,'furniture'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'cooker'); ?>
		<?php echo $form->checkBox($model,'cooker'); ?>
		<?php echo $form->error($model,'cooker'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'wash_machine'); ?>
		<?php echo $form->checkBox($model,'wash_machine'); ?>
		<?php echo $form->error($model,'wash_machine'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'fridge'); ?>
		<?php echo $form->checkBox($model,'fridge'); ?>
		<?php echo $form->error($model,'fridge'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'cost'); ?>
		<?php echo $form->textField($model,'cost'); ?>
		<?php echo $form->error($model,'cost'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'area'); ?>
		<?php echo $form->textField($model,'area'); ?>
		<?php echo $form->error($model,'area'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'phone'); ?>
		<?php echo $form->textField($model,'phone'); ?>
		<?php echo $form->error($model,'phone'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'description'); ?>
		<?php echo $form->textArea($model,'description'); ?>
		<?php echo $form->error($model,'description'); ?>
	</div>	
	<div class="row">
		<?php echo $form->labelEx($model,'manager_comment'); ?>
		<?php echo $form->textArea($model,'manager_comment'); ?>
		<?php echo $form->error($model,'manager_comment'); ?>
	</div>
	<ul id="pikame" >
		<?php $Params = array( 'zc'=>1,/* зоом с вырезанием */); ?>
		<?php foreach ($model->homePhotoses as $image) { ?>
			<?php 
			$src = Home::getFolder($image->path, false).$image->path;
			$srcSmall = ImageResizer::resizeImage($src, array('w'=>263, 'h'=>338), 0, $Params, 'catalog');
			?>
			<li><img src="<?php if ($srcSmall) echo $srcSmall; else echo $src; ?>"></li>
		<?php } ?>
		</ul>
	<div class="row buttons">
		<?php echo CHtml::submitButton('Сохранить'); ?>
	</div>
<?php $this->endWidget(); ?>
</div>